package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

func MyHandler(c *gin.Context) {
	fmt.Println("MyHandler...")
}

func MyHandlerB() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		path := ctx.FullPath()
		method := ctx.Request.Method
		fmt.Println("MyHandlerB...\npath: ", path, "\nmethod: ", method)
	}
}

func main() {

	r := gin.Default()
	r.Use(MyHandler, MyHandlerB())

	r.GET("/hello", func(c *gin.Context) {
		c.JSON(200, gin.H{"message": "Hello world!"})
	})

	r.Run()
}
